package Metier;

/**
 * *********************************************************************
 * Module: News.java Author: Loick Purpose: Defines the Class News
 * *********************************************************************
 */
import Affichage.CustomPanel;
import java.util.*;
import javax.swing.JFrame;

public class News extends JFrame {

    private List<Descriptable> listeDesElementsAjoutes = new ArrayList<>();
    private javax.swing.JButton BTNValiderCarte;
    private javax.swing.JLabel LBLSelectionnerCarte;
    private javax.swing.JList<String> LSTCartes;
    private javax.swing.JScrollPane jScrollPane1;
    private List<Lieu> c = new ArrayList<>();
    private Vector<String> v;
    private Dialogue dialog;

    public void historiser(Descriptable e) {
        listeDesElementsAjoutes.add(e);
    }

    public List<Descriptable> getList() {
        return this.listeDesElementsAjoutes;
    }

    public void afficher_news() {
        List<String> News = dialog.getNews();
        
        setTitle("News");
        
        for (String lieu : News) {
            String[] carac = lieu.split("/");
            v.add(lieu);
        }
        LSTCartes.setListData(v);

        jScrollPane1.setViewportView(LSTCartes);
        
        LBLSelectionnerCarte.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        LBLSelectionnerCarte.setText("Voici les derniers éléments ajoutés");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(109, 109, 109))
                .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(LBLSelectionnerCarte)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(LBLSelectionnerCarte)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)
                        .addGap(18, 18, 18))
        );
        this.setSize(400,300);
        this.setVisible(true);
    }

    public News() {
        dialog = new Dialogue();
        BTNValiderCarte = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        LSTCartes = new javax.swing.JList<String>(v);
        LBLSelectionnerCarte = new javax.swing.JLabel();
        v = new Vector<String>();

    }
}
